<?php 
/**
* 
*/
class Reports extends record
{
	
	function __construct()
	{
		$this->namaTabel = '';
	}

	function getPenjualan($dari,$sampai,$arrParam=array()){
		$sW = '';
		if(is_array($arrParam) && count($arrParam)>0){
			$aW  = array( );
			foreach ($arrParam as $key => $value) {
				$aW[]= $key."` = '".$value;
			}
			$sW = 'AND (`'.implode("' AND `",$aW)."' )";
		};
		$s = 'SELECT p.tanggal
		,p.status_pesan
		,p.alamat
		,p.id_pemesanan
		,u.nama
		,u.nama AS pemproses,
		c.nama AS pemesan
		FROM pemesanan p 
		LEFT JOIN user u ON u.id = p.idadmin
		LEFT JOIN customer c ON c.id = p.idcus
		WHERE p.tanggal BETWEEN "'.$dari.'" AND "'.$sampai.'" '.$sW;
		
		/*$s = "SELECT pd.harga,pd.h_modal,pd.jumlah_buy,pd.diskon,
		p.tanggal
		,p.status_pesan
		,p.alamat
		,p.id_pemesanan
		,u.nama
		,vp.nama as nama_produk,
		u.nama AS pemproses,
		c.nama AS pemesan
		 FROM pesanan_detail pd 
		LEFT JOIN pemesanan p ON pd.id_pesanan = p.id_pemesanan
		LEFT JOIN user u ON u.id = p.idadmin
		LEFT JOIN customer c ON c.id = p.idcus
		LEFT JOIN v_produk vp ON vp.id = pd.id_produk
		WHERE p.tanggal BETWEEN '".$dari."' AND '".$sampai."' ".$sW;
		*/
		$this->query($s);
		return $this->execute();
	}
	function getDetailPenjualan($id){
		$S='SELECT * FROM pesanan_detail pd
		LEFT JOIN v_produk vp ON vp.id = pd.id_produk
		WHERE pd.id_pesanan="'.$id.'"';
		$this->query($S);
		return $this->execute();

	}
}
$objReports = new Reports();